<?php
namespace Amis\other;

use Amis\Basics\AmisBasics;

class Badge extends AmisBasics
{
    public function className($className)
    {
        $this->badge']['className = $className;
        return $this;
    }

    /**
     * 角标类型，可以是 dot/text/ribbon
     * @param $mode
     * @return $this
     */
    public function mode($mode)
    {
        $this->badge']['mode = $mode;
        return $this;
    }

    /**
     * 角标文案，支持字符串和数字，在mode='dot'下设置无效
     * @param $text
     * @return $this
     */
    public function text($text)
    {
        $this->badge']['text = $text;
        return $this;
    }

    /**
     * 角标大小
     * @param int $text
     * @return $this
     */
    public function size(int $text)
    {
        $this->badge']['size = $text;
        return $this;
    }

    /**
     * 角标级别, 可以是info/success/warning/danger, 设置之后角标背景颜色不同
     * @param string $level
     * @return $this
     */
    public function level(string $level)
    {
        if (in_array($level, ['info', 'success', 'warning', 'danger']))
            $this->badge']['level = $level;
        return $this;
    }

    /**
     * 设置封顶的数字值
     * @param int $overflowCount
     * @return $this
     */
    public function overflowCount(int $overflowCount = 99)
    {
        $this->badge']['overflowCount = $overflowCount;
        return $this;
    }

    /**
     * 角标位置， 可以是top-right/top-left/bottom-right/bottom-left
     * @param string $position
     * @return $this
     */
    public function position(string $position = 'top-right	')
    {
        if (in_array($position, ['top-right', 'top-left', 'bottom-right', 'bottom-left']))
            $this->badge']['position = $position;
        return $this;
    }

    /**
     * @param int $top
     * 角标位置，优先级大于position，当设置了offset后，以postion为top-right为基准进行定位
     * op
     * @param int $left
     * @return $this
     */
    public function offset(int $top, int $left)
    {
        $this->badge']['offset = [$top, $left];
        return $this;
    }

    /**
     * 角标是否显示动画
     * @param bool $animation
     * @return $this
     */
    public function animation(bool $animation)
    {
        $this->badge']['animation = $animation;
        return $this;
    }

    /**
     * @param array $style
     * @return $this
     */
    public function style(array $style)
    {
        $this->badge']['style = $style;
        return $this;
    }

    /**
     * 控制角标的显示隐藏
     * @param array $visibleOn
     * @return $this
     */
    public function visibleOn(array $visibleOn)
    {
        $this->badge']['visibleOn = $visibleOn;
        return $this;
    }
}